<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateVipPurchasesTable extends Migration
{
    public function up()
    {
        Schema::create('vip_purchases', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->index()->default(0);
            $table->string('number')->unique()->comment('order number of this upgrade');
            $table->decimal('total_amount', 10, 2)->default(0);
            $table->dateTime('paid_at')->nullable();
            $table->string('paid_method')->nullable()->comment('method of payment');
            $table->string('paid_number')->nullable()->comment('payment number of third party');
            $table->dateTime('closed_at')->nullable();
            $table->dateTime('cancelled_at')->nullable();
            $table->string('refund_number')->nullable()->index();
            $table->string('refund_status')->default('pending');
            $table->text('refund_failed_reason')->nullable();
            $table->timestamps();
        });
    }
    
    public function down()
    {
        Schema::dropIfExists('vip_purchases');
    }
}
